package com.blacktry.mapper.blog;

import com.blacktry.entity.blog.Labels;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.blacktry.entity.model.vueVO.Option;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author blackTry
 * @since 2022-02-07
 */
public interface LabelsMapper extends BaseMapper<Labels> {

    //根据标签名称查询标签ID;
    public  Integer selectId(String labelName);

    @Select("select label_id as value,label_name as label from labels")
    List<Option> selectLabelsOptions();

    @Select("select labels.label_id as value,labels.label_name as label from article_label,labels where article_label.article_id = #{id} and article_label.label_id = labels.label_id")
    List<Option> selectOneLabelsOptions(String id);

    @Select("select labels.label_name from article_label,labels where article_label.article_id = #{id} and article_label.label_id = labels.label_id")
    String[] backOneLabelsOptions(String id);
}
